#coding:utf-8
from lovewith.promote.models import PromoteGoodsCommandTag
from lovewith.utils.mtcache import MtCache


class GoodsAttachTagApi:
    def __init__(self):
        pass

    #获取全部标签
    @staticmethod
    def get_all():
        command_goods_tag = MtCache('command_goods_tag').get()

        if not command_goods_tag:
            command_goods_tag = []

            cate_filter_data = PromoteGoodsCommandTag.objects.all()
            for data in cate_filter_data:
                #替换中文逗号
                tag = data.tags.replace('，', ',').split(',')
                command_goods_tag.extend(tag)

            MtCache('command_goods_tag').set(command_goods_tag)

        return command_goods_tag